package 多线程.同步;

public class SaleThread implements Runnable{
    int tickets=10;
    @Override
    public void run() {
        while (true){
            saleTicket();
            if (tickets<=0)
                break;
        }
    }

    public synchronized void saleTicket(){
        while (tickets>0){
            System.out.println(Thread.currentThread().getName()+"---"+tickets--);
        }
    }
}
